package com.hxzy.springbootes.es.entity;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.hxzy.springbootes.mybatis.entity.TbHotel;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;

import java.io.Serializable;

/**
 * @Author wy
 * @Description TODO
 * @Date 2023/5/31 15:43
 * @Version 1.0
 */
@Getter
@Setter
//indexName=索引库名,createIndex=false不要自动创建索引库
@Document(indexName = "hotel",createIndex = false)
public class EsHotel implements Serializable {

    /**
     * 索引主键
     */
    @Id
    private Long id;

    private String name;
    private String address;
    private Integer price;
    private Integer score;
    private String brand;
    private String city;

    private String starname;
    private String business;

    /**
     *  经纬度
     *  1. 字符串
     *    `位置：lat + "," + lon`
     * 2. 数组
     *    `位置: {"lat": ...,"lon": ...}`
     * 3. 对象
     *    `位置: [lon, lat]`
     */
    private String location;
    private String pic;

    public EsHotel() {
    }

    /**
     * mysql数据库值
     * @param hotel
     */
    public EsHotel(TbHotel hotel){
        this.id = hotel.getId();
        this.name = hotel.getName();
        this.address = hotel.getAddress();
        this.price = hotel.getPrice();
        this.score = hotel.getScore();
        this.brand = hotel.getBrand();
        this.city = hotel.getCity();
        this.starname = hotel.getStarName();
        this.business = hotel.getBusiness();
        this.location = hotel.getLatitude() + ", " + hotel.getLongitude();
        this.pic = hotel.getPic();
    }


}
